#include "Bullet.h"
#include "GameConstants.h"


Bullet::Bullet(void):
	_active(false),
	_colider(GameConstants::MODELS["Cube"],Vector3<float>(0,0,0),10)
{
	_colider._color = MyColor(1,0,0.5,1);
	_colider.Scale() = Vector3<float>(2,2,2);
}


Bullet::~Bullet(void)
{
}

Colider* Bullet::Model() { return &_colider; }

void Bullet::Draw()
{
	_colider.Draw();
}

void Bullet::Update()
{
	if(_active)
	{
		_colider.Translate(_colider.Velocity());
		_colider.TransformPoints();
		if(_colider.Position().Magnitude() > 400)
		{
			_active = false;
		}
	}
}

bool& Bullet::Active()
{
	return _active;
}

void Bullet::Fire(Vector3<float> position, Vector3<float> velo)
{
	_active = true;
	_colider.TranslateTo(position);
	_colider.Velocity() = velo;
	_colider.Rotation() = Quaternion::AxisAngle(_colider.Z_FORWARD.Cross(velo),
												Vector3<float>::AngleBetween(_colider.Z_FORWARD, velo));
}
